package edu.zut.cs.software.perfect.process.service.impl;

import java.util.List;
import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.perfect.base.service.impl.GenericManagerImpl;
import edu.zut.cs.software.perfect.course.domain.CourseInformation;
import edu.zut.cs.software.perfect.process.dao.CourseProcessDao;
import edu.zut.cs.software.perfect.process.domain.CourseProcess;
import edu.zut.cs.software.perfect.process.service.CourseProcessManager;;

/**
 * @ClassName courseProcessManagerImpl
 * @Description TODO
 * @Author niu-xi
 * @Date 2020年3月22日
 * @Version 1.0
 */
@Service("courseProcessManager")
@Transactional
public class CourseProcessManagerImpl extends GenericManagerImpl<Long, CourseProcess> implements CourseProcessManager {

	CourseProcessDao courseProcessDao;
	
	@Autowired
	public void setCourseProcessDao(CourseProcessDao courseProcessDao) {
		this.courseProcessDao = courseProcessDao;
		this.dao=this.courseProcessDao;
	}


	@Override
	public List<CourseProcess> findAll() {
		return (List<CourseProcess>) this.dao.findAll();
	}

	@Override
	public Optional<CourseProcess> findByCourseId(Long courseId) {
		Optional<CourseProcess> result = this.dao.findById(courseId);
		return result;
	}

	@Override
	public Boolean deleteById(Long courseId) {
		Optional<CourseProcess> courseProcess = this.dao.findById(courseId);
		if(courseProcess.equals(Optional.empty())) {
			return false;
		} else {
			this.dao.delete(courseProcess.get());
			return true;
		}
	}

}
